package com.atguigu.controller;

import com.atguigu.pojo.Student;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: liuaojun
 * @CreateTime: 2025-01-18
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/TestParam")
public class TestParam {
    /**
    * @Author:liuaojun
    * @Date:2025-01-18 10:47
    * @Description:测试默认情况+@RequestParam
    */
    @GetMapping("/test1")
    public String test1(String name,@RequestParam("sage") Integer age){
        System.out.println("name = " + name);
        System.out.println("age = " + age);
        return "name:"+name+",age:"+age;
    }
    /**
    * @Author:liuaojun
    * @Date:2025-01-18 10:52
    * @Description:测试POJO入参
    */
    @PostMapping("/test2")
    public String test2(Student student){
        System.out.println("student = " + student);
        return "student:"+student;
    }

    /**
    * @Author:liuaojun
    * @Date:2025-01-18 13:45
    * @Description:测试JSON入参
    */
    @PostMapping("/test3")
    public String test3(@RequestBody Student student){
        System.out.println("student = " + student);
        return "student:"+student;
    }

    /**
     * @Author:liuaojun
     * @Date:2025-01-18 13:45
     * @Description:测试JSON入参
     */
    @PostMapping("/test4")
    public String test4(@RequestBody String jsonStr){
        System.out.println("student = " + jsonStr);
        return "jsonStr:"+jsonStr;
    }


}
